package com.sc.socket.chatroom.server;

import com.sc.socket.chatroom.constants.TCPConstants;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author shuc001
 * @Date 2019-02-05 11:11
 */
public class Server {
    public static void main(String[] args) throws IOException {
        TCPProvider tcpProvider = new TCPProvider(TCPConstants.TCP_PORT);
        boolean succ = tcpProvider.start();
        if(!succ){
            System.out.println("tcp启动失败");
            return;
        }
        UDPProvider.start(TCPConstants.TCP_PORT);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String str;
        do{
            str = bufferedReader.readLine();
            tcpProvider.sendBroad(str);
        }while (!"byebye".equalsIgnoreCase(str));
        UDPProvider.stop();
        tcpProvider.stop();
    }
}
